/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.test_factory;

import picounit.features.Feature;
import picounit.features.aggregate_exception.Thrower;
import picounit.features.base.FeatureRegistry;
import picounit.features.class_finder.ClassFinder;
import picounit.features.instrumentation.InstrumentationController;
import picounit.features.mock_collaborator_injection.CollaboratorsInvocationHandler;
import picounit.features.registry.RegistryFactory;
import picounit.features.signature_factory.SignatureFactoryFactory;
import picounit.features.test_instantiator.InvokerFactory;
import picounit.features.test_instantiator.OrdinaryInstantiatorFactory;
import picounit.mocker.MockControl;

public class TestFactoryFeature implements Feature {
	private final RegistryFactory registryFactory;
	private final ClassLoader classLoader;
	private final Thrower thrower;
	private final InstrumentationUpdatingTestListener testListener;
	private final SignatureFactoryFactory signatureFactoryFactory;
	private final MockControl mockControl;
	private final CollaboratorsInvocationHandler collaboratorsInvocationHandler;
	private final ClassFinder classFinder;
	
	public TestFactoryFeature(RegistryFactory registryFactory, ClassLoader classLoader,
		SignatureFactoryFactory signatureFactoryFactory, Thrower thrower,
		InstrumentationController instrumentationController, MockControl mockControl,
		CollaboratorsInvocationHandler collaboratorsInvocationHandler, ClassFinder classFinder) {

		this.registryFactory = registryFactory;
		this.classLoader = classLoader;
		this.signatureFactoryFactory = signatureFactoryFactory;
		this.thrower = thrower;
		this.mockControl = mockControl;
		this.collaboratorsInvocationHandler = collaboratorsInvocationHandler;
		this.classFinder = classFinder;
		this.testListener = new InstrumentationUpdatingTestListener(instrumentationController);
	}

	public void addFeatures(FeatureRegistry featureRegistry) {
		featureRegistry.addFeatures(new TestFactory(registryFactory, classLoader, thrower,
			testListener, mockControl, collaboratorsInvocationHandler, classFinder,
			new InvokerFactory(signatureFactoryFactory),
			new OrdinaryInstantiatorFactory(signatureFactoryFactory)));
	}
}
